package condominio.servlet.vivienda;

import java.io.IOException;

import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import condominio.excepcion.DAOExcepcion;
import condominio.negocio.GestionViviendas;

/**
 * Servlet implementation class ViviendaBuscar
 */
@WebServlet("/ViviendaBuscar")
public class ViviendaBuscar extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public ViviendaBuscar() {
        super();
        // TODO Auto-generated constructor stub
    }

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		
		

		String bcodigo =  request.getParameter("bcodigo");
		String edif =  request.getParameter("edifzona");
		String cviv	=  request.getParameter("codviv");
		String numeroviv	=  request.getParameter("numviv");
		String metraje	=  request.getParameter("metraje");
		
		GestionViviendas negocio1 = new GestionViviendas();
		
		
	
		try {
			
								
			negocio1.insertar(Integer.parseInt(cviv),Integer.parseInt(edif),Integer.parseInt(numeroviv),Integer.parseInt(metraje),bcodigo);
			response.sendRedirect(request.getContextPath()	+ "/RegistroViviendaExito.jsp");
		} catch (DAOExcepcion e) {
			RequestDispatcher rd = request.getRequestDispatcher("errorVivienda.jsp");
			rd.forward(request, response);
		}
		
		
	}

}
